﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>sample of using DOM API</title>
    <script type="text/javascript">
        function log(msg) {
            var logger = document.getElementById("log");

            if (!logger) {
                logger = document.createElement("div");
                logger.id = "log";
                logger.innerHTML = "<h1>Debug Log</h1>";
                document.body.appendChild(logger);
            }

            var text = document.createTextNode(msg);

            var preserve = document.createElement("pre");
            preserve.appendChild(text);

            logger.appendChild(preserve);
        }

    </script>
</head>
<body>
    <script type="text/javascript">
        var testmsgs = ["hello", "world", "              javascript     useful"];
        for (var i = 0; i < testmsgs.length; i++) {
            log(testmsgs[i]);
        }
    </script>
</body>
</html>
